<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/11/7
  Time: 14:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>超市账单管理系统</title>
    <link rel="stylesheet" href="${pageContext.servletContext.contextPath}/statics/css/public.css"/>
    <link rel="stylesheet" href="${pageContext.servletContext.contextPath}/statics/css/style.css"/>
</head>
<body>
<!--头部-->
<jsp:include page="comon/header.jsp"></jsp:include>
<!--主体内容-->
<section class="publicMian">
    <jsp:include page="comon/left.jsp"></jsp:include>
    <div class="right">
        <div class="location">
            <strong>你现在所在的位置是:</strong>
            <span>用户管理页面 >> 用户添加页面</span>
        </div>
        <div class="providerAdd">
            <form action="${pageContext.servletContext.contextPath}/user/doadduser2" method="post" enctype="multipart/form-data" >
                <!--div的class 为error是验证错误，ok是验证成功-->
                <div class="">
                    <label for="userCode">用户编码：</label>
                    <input type="text" name="userCode" id="userCode"  />
                    <span>*请输入用户编码，且不能重复</span>
                </div>
                <div>
                    <label for="userName">用户名称：</label>
                    <input type="text" name="userName" id="userName"/>
                    <span >*请输入用户名称</span>
                </div>
                <div>
                    <label for="userpassword">用户密码：</label>
                    <input type="text" name="userPassword" id="userpassword"/>
                    <span>*密码长度必须大于6位小于20位</span>

                </div>
                <div>
                    <label for="userRemi">确认密码：</label>
                    <input type="text" name="userRemi" id="userRemi"/>
                    <span>*请输入确认密码</span>
                </div>
                <div>
                    <label >用户性别：</label>

                    <select name="gender">
                        <option value="0">男</option>
                        <option value="1">女</option>
                    </select>
                    <span></span>
                </div>
                <div>
                    <label for="data">出生日期：</label>
                    <input type="date" name="birthday" id="data"/>
                    <span >*</span>
                </div>
                <div>
                    <label for="userphone">用户电话：</label>
                    <input type="text" name="phone" id="userphone"/>
                    <span >*</span>
                </div>
                <div>
                    <label for="userAddress">用户地址：</label>
                    <input type="text" name="address" id="userAddress"/>
                </div>
                <div>
                    <label >用户类别：</label>
                    <input type="radio" name="userRole" value="1"/>管理员
                    <input type="radio" name="userRole" value="2"/>经理
                    <input type="radio" name="userRole" value="3"/>普通用户

                </div>

                <div>
                    <label for="id_picPath">用户头像：</label>
                    <input type="file" name="attachs" id="id_picPath"/>
                </div>
                <div>
                    <label for="work_picPath">用户工作照片：</label>
                    <input type="file" name="attachs" id="work_picPath"/>
                </div>

                <div class="providerAddBtn">
                    <!--<a href="#">保存</a>-->
                    <!--<a href="userList.html">返回</a>-->
                    <input type="submit" value="保存" />
                    <input type="button" value="返回" onclick="history.back(-1)"/>
                </div>
            </form>
        </div>
    </div>

</section>
<jsp:include page="comon/foot.jsp"></jsp:include>
</body>
</html>
<script src="${pageContext.servletContext.contextPath}/statics/js/jquery.js"></script>
<script>

    $(function () {
        $("#userCode").blur(function () {
           var userCode = $(this).val();
           //ajax請求後端數據接口
            $.ajax({
                url: "isexistcode",
                type:"get",
                dataType:"json",
                data:{"userCode":userCode},
                success:function(data){
                    if(data.success){
                        $("#userCode").next().html("<span style='color: green'>"+data.msg+"<span>")
                    }else{
                        $("#userCode").next().html("<span style='color: red'>"+data.msg+"<span>")
                    }

                },
                error:function () {
                    console.log("请求异常")
                },
                complete:function () {
                    console.log("请求结束")
                }
            })
        })
    })



</script>